CC=msp430-gcc
OBJDUMP=msp430-unknown-elf-objdump
MSPDEBUG=/export/msp430/bin/mspdebug

# BSD make demands being pedantic over CFLAGS..
CPPFLAGS=-I/export/msp430/include -mmcu=msp430g2553
DBG=-g
CFLAGS=$(CPPFLAGS) $(DBG)

LDFLAGS=-nostartfiles -Tmemory.ld -nostdlib 
OBJS=neko.o
EXE=neko.elf
SRC=neko.S

all: $(OBJS)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $(EXE) $(OBJS)

asm:
	$(OBJDUMP) -d $(EXE)

upload:
	sudo $(MSPDEBUG) rf2500 "prog $(EXE)"

%.o: %.S
	$(CC) $(CFLAGS) -c $<

clean:
	rm -fr $(EXE) $(OBJS)

autobuild:
	while true; do if [ $(EXE) -ot $(SRC) ]; then make -f Makefile.neko; fi; echo; sleep 2;done
